1. Field of the Invention
The present invention relates to a computer program product, system, and method for processing read and write requests in a sequential access storage device having a non-volatile storage cache.
2. Description of the Related Art
A cache management system buffers tracks in a storage device recently accessed as a result of read and write operations in a faster access storage device, such as memory, than the storage device storing the requested tracks. Subsequent read requests to tracks in the faster access cache memory are returned at a faster rate than returning the requested tracks from the slower access storage, thus reducing read latency. The cache management system may also return complete to a write request when the modified track directed to the storage device is written to the cache memory and before the modified track is written out to the storage device, such as a hard disk drive. The write latency to the storage device is typically significantly longer than the latency to write to a cache memory. Thus, using cache also reduces write latency.
A cache management system may maintain a linked list having one entry for each track stored in the cache, which may comprise write data buffered in cache before writing to the storage device or read data. In the commonly used Least Recently Used (LRU) cache technique, if a track in the cache is accessed, i.e., a cache “hit”, then the entry in the LRU list for the accessed track is moved to a Most Recently Used (MRU) end of the list. If the requested track is not in the cache, i.e., a cache miss, then the track in the cache whose entry is at the LRU end of the list may be removed (or destaged back to storage) and an entry for the track data staged into cache from the storage is added to the MRU end of the LRU list. With this LRU cache technique, tracks that are more frequently accessed are likely to remain in cache, while data less frequently accessed will more likely be removed from the LRU end of the list to make room in cache for newly accessed tracks.
The LRU cache technique seeks to optimize for temporal locality so as to destage tracks that are least likely to be rewritten soon in order to minimize the number of destage operations, i.e., if a write that is not destaged is overwritten than the destaging of the overwritten write is avoided, thus saving the time and effort of writing the data from cache to disk. On the other hand there is also a desire to destage in a manner that exploits spatial locality, which means that data is written to storage locations that are closest to each other to minimize the distance the storage device write mechanism and storage media needs to be moved to reach the next storage location to write.
One technique for exploiting both temporal and spatial locality is the Wise Ordering for Writes (WOW) algorithm. The WOW algorithm employs a circular linked list or clock where the circular linked list has one entry for each write request buffered in cache. The entries are ordered in the linked list according to the storage location to which the associated write request is directed to exploit the benefits of spatial locality. Further, each entry includes a bit indicating whether the write data for the storage location in the cache has been recently updated. The bit for an entry is set when the write data for the entry is updated. A pointer points to a current entry in the circular linked list. A task using the WOW algorithm accesses an entry addressed by the pointer. If the bit for the entry indicates that the data for the entry in cache has been recently updated, then the bit is set to indicate that the write data has not been recently updated and the pointer incremented to point to the next entry so that the entry having write data to a storage location next closest in spatial proximity to the previously written storage location is considered. The entry is selected to write that is closest in spatial proximity to the last written storage location and whose bit indicates that the write data for the entry has not recently been updated.
Thus, with the WOW algorithm, spatial locality is exploited because a next entry to write is selected for consideration that is closest in spatial proximity to the last destaged write request. Further, temporal locality is exploited because an entry that has recently been written will be skipped until the pointer circles back to that skipped entry to consider.
Disk drives may implement the WOW algorithm and other algorithms that take both the linear and the angular position of the write tracks into account and optimize for both with respect to a current write head position to determine the minimal total service time. This process is referred to as “command re-ordering based on seek and rotational optimization”. The disk drive logic boards will analyze write requests and determine which to do first based on both how much time will be required to seek to the various cylinders and angular position of the track to write, and how much time will elapse waiting for the data to rotate under the heads.
There is a need in the art for improved techniques for using cache in a storage system.